package com.ruoyi.statisticalCenter.controller;

import java.util.List;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.statisticalCenter.domain.vo.ScCustomerBadDebtVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statisticalCenter.domain.ScCustomerBadDebt;
import com.ruoyi.statisticalCenter.service.IScCustomerBadDebtService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户账单核销Controller
 *
 * @author pyx
 * @date 2024-03-01
 */
@RestController
@RequestMapping("/sc/debt")
@Api(tags = "统计中心-客户账单核销")
public class ScCustomerBadDebtController extends BaseController
{
    @Autowired
    private IScCustomerBadDebtService scCustomerBadDebtService;

    /**
     * 查询客户账单核销列表
     */
    @PostMapping("/list")
    @ApiOperation("查询客户账单核销列表")
    public R list(@RequestBody ScCustomerBadDebtVo scCustomerBadDebtVo)
    {
        List<ScCustomerBadDebt> list = scCustomerBadDebtService.collect(scCustomerBadDebtVo);
        if (list == null || list.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(list));
        }
    }


    /**
     * 新增客户账单核销
     */
    @PostMapping("/add")
    @ApiOperation("新增客户账单核销")
    public R addSave(@RequestBody ScCustomerBadDebt scCustomerBadDebt)
    {
        return scCustomerBadDebtService.insertScCustomerBadDebt(scCustomerBadDebt);
    }


    /**
     * 修改客户账单核销
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ScCustomerBadDebt scCustomerBadDebt)
    {
        return toAjax(scCustomerBadDebtService.updateScCustomerBadDebt(scCustomerBadDebt));
    }

    /**
     * 删除客户账单核销
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(scCustomerBadDebtService.deleteScCustomerBadDebtByIds(ids));
    }
}
